const { defineConfig } = require('@vue/cli-service')
const Mock = require("mockjs")
let data = Mock.mock({
  "list":[{
    
    "title":"热门",
    "children|10":[{
       tit:"@ctitle",
       img:"@image(150x150,@color)",
       "price|10-800":10,
       id:"@id",
       checked:false
    }]
  },
  {
    "title":"男装",
    "children|10":[{
       tit:"@ctitle",
       img:"@image(150x150,@color)",
       "price|10-800":10,
       id:"@id",
       checked:false
    }]
  },
  {
    "title":"女装",
    "children|10":[{
       tit:"@ctitle",
       img:"@image(150x150,@color)",
       "price|10-800":10,
       id:"@id",
       checked:false
    }]
  },
  {
    "title":"内衣",
    "children|10":[{
       tit:"@ctitle",
       img:"@image(150x150,@color)",
       "price|10-800":10,
       id:"@id",
       checked:false
    }]
  }
]
}).list
module.exports = defineConfig({
  transpileDependencies: true,
  devServer:{
    onBeforeSetupMiddleware({app}){
        app.get("/list",(req,res)=>{
          console.log(req.query);
          let filterdata =  data.filter((item,index)=>{
                return item.title == req.query.title
          })
          console.log(filterdata);
          res.send(filterdata[0])
         
        })
    }
  }
})
